package com.emapp.lccode.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.emapp.lccode.base.BaseApplication
import com.emapp.lccode.bean.OrderKt
import com.emapp.lccode.databinding.ListitemOrderBinding

class MyOrderKtAdapter : BaseQuickAdapter<OrderKt, MyOrderKtAdapter.VH>() {

    class VH(
        parent: ViewGroup,
        val binding: ListitemOrderBinding = ListitemOrderBinding.inflate(
            LayoutInflater.from(parent.context), parent, false
        ),
    ) : RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
        return VH(parent)
    }

    override fun onBindViewHolder(holder: VH, position: Int, item: OrderKt?) {
        if (item?.name?.isEmpty() == true) {
            holder.binding.tvName.text = "无"
        } else
            holder.binding.tvName.text = item?.name
        holder.binding.tvAddress.text = item?.address
        holder.binding.tvTime.text = item?.create_time
        holder.binding.tvType.text = item?.flow_type
        holder.binding.tvReply.visibility = View.GONE
        when (item?.check_status) {
            0 -> {//未派单
                if (item?.checkIds?.contains(BaseApplication.instance.adminId.toInt()) == true) {//该我派单
                    holder.binding.tvState.text = "待派单"
                } else
                    holder.binding.tvState.text = "待审核"
            }

            1 -> {//派单后
                if (item?.checkIds?.contains(BaseApplication.instance.adminId.toInt()) == true) {//该我回复了
                    holder.binding.tvState.text = "待回复"
                } else
                    holder.binding.tvState.text = "已派单"
            }

            2 -> {
                holder.binding.tvState.text = "已回复"
            }

            3 -> {
                holder.binding.tvState.text = "审核不通过"
            }

            4 -> {
                holder.binding.tvState.text = "撤销审核"
            }
        }
    }


}